package service

import (
	"gitee.com/Luna-CY/Golang-Project-Template/internal/errors"
	"gitee.com/Luna-CY/Golang-Project-Template/internal/util/pointer"
	"gitee.com/Luna-CY/Golang-Project-Template/model"
)

type BusinessExampleField field[model.BusinessExample]

func BusinessExampleFieldWithName(name string) BusinessExampleField {
	return func(example *model.BusinessExample) errors.Error {
		example.Name = pointer.New(name)

		return nil
	}
}

func BusinessExampleFieldWithValue(value uint64) BusinessExampleField {
	return func(example *model.BusinessExample) errors.Error {
		example.Value = pointer.New(value)

		return nil
	}
}

func BusinessExampleFieldWithEnable(enable bool) BusinessExampleField {
	return func(example *model.BusinessExample) errors.Error {
		example.Enable = pointer.New(enable)

		return nil
	}
}

func BusinessExampleFieldWithType(fieldType model.BusinessExampleEnumFieldType) BusinessExampleField {
	return func(example *model.BusinessExample) errors.Error {
		example.Type = pointer.New(fieldType)

		return nil
	}
}

func BusinessExampleFieldWithImageId(image *model.SystemObject) BusinessExampleField {
	return func(example *model.BusinessExample) errors.Error {
		if nil == image {
			example.ImageId = pointer.New("")

			return nil
		}

		example.ImageId = pointer.New(image.Id)

		return nil
	}
}
